local skill = fk.CreateSkill {
  name = "kq__yingwu",
}

skill:addEffect(fk.EventPhaseStart, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skill.name) and target.phase == Player.Play and target == player
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local use = room:askToUseVirtualCard(player, {
      name = "duel",
      skill_name = skill.name,
      prompt = "#kq__yingwu",
      cancelable = true,
      extra_data = {
        bypass_times = true,
        extraUse = true,
      },
      card_filter = {
        n = (#player:getCardIds("h")+#player:getCardIds("e"))//2,
        handly_pile = true,
      },
      skip = true,
    })
    if use then
      event:setCostData(self, {extra_data = use})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local use = event:getCostData(self).extra_data
    room:useCard(use)
  end,
})

skill:addEffect(fk.DamageCaused, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and data.card and table.contains(data.card.skillNames, "kq__yingwu") and data.to
    and data.to~=player
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local cnt = false
    for _, i in ipairs(data.card.subcards) do
      if Fk:getCardById(i).type == Card.TypeEquip  then
          cnt = true
      end
    end
    if cnt then
      data:changeDamage(1)
    end
  end,
})


Fk:loadTranslationTable{
  ["kq__yingwu"] = "英武",
  [":kq__yingwu"] = "出牌阶段开始时，你可以将你半数的牌当【决斗】 使用（向下取整），若此【决斗】对应的实体牌每包含一张装备牌，则对其他角色造成的伤害+1。",
  ["$kq__yingwu1"] = "亘古武烈，止戈平襄，身秉千秋义气。",
  ["$kq__yingwu2"] = "锦衣乌程，戎行南北，收拾万里江山。",
  ["#kq__yingwu"] = "将半数牌当【决斗】使用，若包含装备牌则伤害+1"
}
return skill